﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace ZK.YCGLRD_WindowsService
{
    /// <summary>
    /// 明华读卡器的卡
    /// </summary>
    public class ReaderController : ApiController
    {
        /// <summary>
        /// 获取卡号
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public string GetCardNum()
        {
            Common.SimpleLog.WriteLog("Get  接口被调用数据 ");

            string cardNum = "9999";
            cardNum = Service1.mHSNReader.GetCardNum();
            Common.SimpleLog.WriteLog(cardNum);
            return cardNum;
        }
        /// <summary>
        /// 更新卡号 写卡
        /// </summary>
        /// <param name="oldNum">老卡号</param>
        /// <param name="newNum">新卡号</param>
        /// <returns></returns>
        [HttpGet]
        public bool UpdateCardNum(string oldNum, string newNum)
        {
            try
            {
                Common.SimpleLog.WriteLog("UpdateCardNum 接口被调用数据 " + oldNum + " " + newNum);
                Service1.mHSNReader.WriteCard(oldNum, newNum);
                Common.SimpleLog.WriteLog("写卡 oldNum：" + oldNum + " newNum" + newNum);
                return true;
            }
            catch (Exception ex)
            {

                Common.SimpleLog.WriteLog("写卡 oldNum：" + oldNum + " newNum" + newNum + " 异常：" + ex.ToString());
                return false;
            }
        }
    }
}
